package cn.xin.user.dto;

import cn.xin.base.util.MD5Utils;
import cn.xin.base.util.StrUtils;
import cn.xin.user.domain.User;
import lombok.Data;

import javax.validation.constraints.NotBlank;
import java.util.Date;

@Data
public class BinderDto {
    //@NotBlank(message = "手机号不能为空")
    private String phone;
    @NotBlank(message = "手机验证码不能为空")
    private String verifyCode;
    @NotBlank(message = "accessToken不能为空")
    private String accessToken;
    @NotBlank(message = "openId不能为空")
    private String openId;

    public User getUser(){
        String salt = StrUtils.getComplexRandomString(32);
        String password = MD5Utils.encrypByMd5(salt + "123");
        return User.builder()
                .username(this.phone)
                .phone(this.phone)
                .salt(salt)
                .password(password)
                .state(1)
                .createtime(new Date())
                .build();
    }

}
